function Rectangle(name, width, height) {
    this.name = name;
    this.width = width;
    this.height = height;
}
   Rectangle.prototype.area = function () {
    return this.width * this.height;
};
   Rectangle.prototype.perimeter = function () {
    return 2 * (this.width + this.height);
};
   Rectangle.prototype.isSquare = function () {
    return this.width === this.height;
};
const rectanglePrototypes = {
    area: function () {
    return this.width * this.height;
},
    perimeter: function () {
    return 2 * (this.width + this.height);
},
    isSquare: function () {
    return this.width === this.height;
},
   };
function createRectangle(width, height) {
  return Object.create(rectanglePrototypes, {
    width: {
    value: width,
    writable: true,
    enumerable: true,
    configurable: true,
    },
    height: {
    value: height,
    writable: true,
    enumerable: true,
    configurable: true,
    },
  });
 }
const rect1 = createRectangle(10, 20);
console.log(rect1);
// 输出：{ width: 10, height: 20 }
console.log(rect1.area());
// 输出：200
console.log(rect1.perimeter());
// 输出：60
console.log(rect1.isSquare());
// 输出：false
console.log(Object.getPrototypeOf(rect1));
// 输出：{ area: [Function: area], perimeter: [Function: perim

   